<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* 
*/
class Home extends MY_Controller
{

	public function __construct()
	{
		parent::__construct();
		
		$this->load->model('Main/IndexModel','home');
	}

	public function index()
	{
		$data = $this->home->count_data();

		$this->load->view('home', $data);
	}


	//获取最新办卡
	public function get_new_card()
	{
		$res = $this->home->card_data();

		if ($res) 
		{
			$data['list'] = $res;
			$data['status'] = 200;
			$data['message'] = '获取成功！';
		}
		else
		{
			$data['list'] = '';
			$data['status'] = 400;
			$data['message'] = '数据获取失败！';
		}

		echo json_encode($data);exit();
	}


	//发布公告
	public function add_notice()
	{
		$this->load->view('notice_info');
	}


	//添加公告到库
	public function insert_notice()
	{
		$field = array('notice_title','content');

		$arr = $this->input->post($field,TRUE);

		$res = $this->home->storage_notice($arr);

		if ($res) 
		{
			$data['status'] = 200;
			$data['message'] = '发布成功！';
		}
		else
		{
			$data['status'] = 400;
			$data['message'] = '发布失败！';
		}

		echo json_encode($data);exit();	
	}

	//获取公告
	public function notice_list()
	{
		$res = $this->home->notice_data();

		if ($res) 
		{
			$data['list'] = $res;
			$data['status'] = 200;
			$data['message'] = '获取成功！';
		}
		else
		{
			$data['list'] = '';
			$data['status'] = 400;
			$data['message'] = '数据获取失败！';
		}

		echo json_encode($data);exit();
	}

	
	
}


?>